﻿//----------------------------------------------------------------------------
//这是创建浮动层

function $(elem) {
    return document.getElementById(elem);
} //返回元素

function LogIn(isbackDiv) { //创建登陆界面
    if ($('floatDiv') == null) {//浮动层是否存在
        var floatDiv = document.createElement('div');
        floatDiv.id = "floatDiv";
        floatDiv.style.position = "absolute";
        floatDiv.style.width = 500 + "px";
        floatDiv.style.height = 500 + "px";
        floatDiv.style.left = (document.documentElement.clientWidth / 2 + document.documentElement.scrollLeft - 250) + "px";
        floatDiv.style.top = (document.documentElement.clientHeight / 2 + document.documentElement.scrollTop - 250) + "px";
        floatDiv.style.zIndex = 1000; //下一行指定弹出样式,及页面
        var loginText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"Login.aspx\" width=\"100%\" height=\"500\"></iframe>";
        var logInText = ""; //弹出样式
        floatDiv.innerHTML = loginText;
        document.body.appendChild(floatDiv);
    }
    else {
        $('floatDiv').style.display = "block";
    }

    if ($('backDiv') == null && isbackDiv == true) {
        var backDiv = document.createElement('div');
        backDiv.id = "backDiv";
        backDiv.style.backgroundColor = "Black";
        backDiv.style.filter = "alpha(opacity=70)";
        backDiv.style.MozOpacity = "0.70";
        backDiv.style.position = "absolute";
        backDiv.style.left = "0px";
        backDiv.style.top = "0px";
        backDiv.style.width = Math.max(document.body.scrollWidth, document.documentElement.clientWidth) + "px";
        backDiv.style.height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight) + "px";
        document.body.appendChild(backDiv);
        $('backDiv').style.zIndex = 1000;
    }
    else if (isbackDiv == true) {
        $('backDiv').style.display = "block";
    }

}

//---------------------------------------------------------------------------------------------------------------------------
//------------这是注册时js检查
var imgName;
function CheckUserName() {
    var userName = document.getElementById("AccountTextBox").value;
    imgName = "username";
    document.getElementById(imgName).innerHTML = "<img src=\"Images/loading.gif\"alt=\"\"/>";

    PageMethods.IsUserNameExist(userName, ShowResult)

}

function CheckPassword() {
    var passWord = document.getElementById("PasswordTextBox").value;
    imgName = "checkpassword";
    document.getElementById("checkpassword").innerHTML = "<img src=\"Images/loading.gif\"alt=\"\"/>";

    PageMethods.CheckPassword(passWord, ShowResult);
}

function CheckTwoPassword() {
    var passWord1 = document.getElementById("PasswordTextBox").value;
    var passWord2 = document.getElementById("PasswordTextBox2").value;
    imgName = "checkpassword2";
    document.getElementById(imgName).innerHTML = "<img src=\"Images/loading.gif\"alt=\"\"/>";
    PageMethods.CheckPasswordSame(passWord1, passWord2, ShowResult);
}

function ShowResult(res) {
    if (res == "ok") {
        document.getElementById(imgName).innerHTML = "<img src=\"Images/right.gif\"alt=\"\"/>";
    }
    else {
        document.getElementById(imgName).innerHTML = "<img src=\"Images/error.gif\"alt=\"\"/>" + res;
    }
}
